<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>修改药品信息</title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui-v2.5.5/layui/layui.all.js"></script>
    <script src="../../layui-v2.5.5/layui/css/layui.css"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
                <tr>
                    <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
                    <td valign="bottom" class="title">修改药品信息</td>
                </tr>
            </table></td>
        </tr>
    </table>
    <form name="form1" method="post" action="">
        <table width="95%"  border="0" cellpadding="0" cellspacing="0">


        <tr>
            <td width="90" align="center" class="td_form01">药房</td>
            <td colspan="3" class="td_form02">
                <select class="phaname">
                    <option value="1">药房A</option>
                    <option value="2">药房B</option>
                    <option value="3">药房C</option>

                </select>
            </td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">药品名称</td>
            <td colspan="3" class="td_form02"><input class="drugname" type="text" readonly></td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">药品数量</td>
            <td colspan="3" class="td_form02"><input class="drugnumber" type="text"></td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">药品单价</td>
            <td colspan="3" class="td_form02"><input class="drugprice" type="text"></td>
        </tr>


        <tr>
            <td width="90" align="center" class="td_form01">药品类别</td>
            <td colspan="3" class="td_form02">
                <select class="druname">
                    <option value="1">片剂</option>
                    <option value="2">胶囊剂</option>
                    <option value="3">注射剂</option>

                </select>
            </td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">生产日期</td>
            <td colspan="3" class="td_form02"><input name="textfield" type="date" class="drugdate"></td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">有效期</td>
            <td colspan="3" class="td_form02"><input name="textfield" type="text" class="dugperiod">个月</td>
        </tr>
        <tr>
            <td width="90" align="center" class="td_form01">库存单位</td>
            <td colspan="3" class="td_form02">
                <select class="pridunit">
                    <option value="1">箱</option>
                    <option value="2">盒</option>
                    <option value="3">瓶</option>

                </select>
            </td>
        </tr>


        <tr>
            <td width="90" align="center" class="td_form01">药品报警日期</td>
            <td colspan="3" class="td_form02"><input name="textfield" type="date" class="drugplidate"></td>
        </tr>

        <tr>
            <td width="90" align="center" class="td_form01">药品报警值</td>
            <td colspan="3" class="td_form02"><input class="drugplival" type="text"></td>
        </tr>
        </table>
        <br>
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td align="center"><input name="Submit" type="button" class="alter" value="修改">
                    <input name="Submit" type="submit" class="buttonface" onClick="window.close()" value="  关闭  "></td>
            </tr>
        </table>
    </form>
</center>
</body>
</html>

<script src="../../js/jquery.js">
</script>
<script>
//解决乱码 并获取url的值
    function getParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)
            return decodeURI(r[2]);   //对参数进行decodeURI解码
        return null;
    }

    $(function() {
        var val1 = getParam("drugname");

        $(".drugname").val(val1);
        // $('#value1').html(val1);
        // $('#value2').html(val2);
    });

    // 调用方法
    //

    <!--绑定按钮单击事件，发送修改药品需要的信息-->
    $(".alter").on("click",function () {
        $.ajax({
            url:"/feign/drugStorageController/alterDrugInfo",
            type:"post",
            headers: {
                Accept: "application/json; charset=utf-8",
                Authorization: location.href.split("=")[1].split("&")[0]
            },
            data:{"drugid":getParam("drugid"),"phaid":$(".phaname").val(),"drugname":$(".drugname").val(),"drugnumber":$(".drugnumber").val(),
                "drugprice":$(".drugprice").val(),"druname":$(".druname option:selected").text(),"drugdate":$(".drugdate").val(),
                "dugperiod":$(".dugperiod").val(),"pridunit":$(".pridunit option:selected").text(),"prid":$(".pridunit").val(),
                "drugplidate":$(".drugplidate").val(),"drugplival":$(".drugplival").val(),"druid":$(".druname").val()},
            dataType: "text",
            success:function (data) {
                console.log(data);
                if(data=="fail"){
                    layer.msg("修改失败，请重新输入")
                }else{
                    layer.msg("修改成功")
                    show();
                }

            }
        })
    })
var timeout = 3;
function show() {
    var showbox = $(".showbox");
    showbox.html(timeout);
    timeout--;
    if (timeout == 0) {
        window.opener = null;
        window.close();
    }
    else {
        setTimeout("show()", 1000);
    }
}
</script>
